package com.sccba.web.controller.yjcz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sccba.common.annotation.Log;
import com.sccba.common.core.controller.BaseController;
import com.sccba.common.core.domain.AjaxResult;
import com.sccba.common.core.page.TableDataInfo;
import com.sccba.common.enums.BusinessType;
import com.sccba.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sccba.emtbusiness.domain.YjczEmergencyProcessTemplate;
import com.sccba.emtbusiness.service.IYjczEmergencyProcessTemplateService;

/**
 * 应急处置操作流程模板Controller
 * 
 * @author lichh
 * @date 2024-04-18
 */
@RestController
@RequestMapping("/yjcz/template")
public class YjczEmergencyProcessTemplateController extends BaseController
{
    @Autowired
    private IYjczEmergencyProcessTemplateService yjczEmergencyProcessTemplateService;

    /**
     * 查询应急处置操作流程模板列表
     */
    @PreAuthorize("@ss.hasPermi('yjcz:template:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjczEmergencyProcessTemplate yjczEmergencyProcessTemplate)
    {
        startPage();
        List<YjczEmergencyProcessTemplate> list = yjczEmergencyProcessTemplateService.selectYjczEmergencyProcessTemplateList(yjczEmergencyProcessTemplate);
        return getDataTable(list);
    }

    /**
     * 导出应急处置操作流程模板列表
     */
    @PreAuthorize("@ss.hasPermi('yjcz:template:export')")
    @Log(title = "应急处置操作流程模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YjczEmergencyProcessTemplate yjczEmergencyProcessTemplate)
    {
        List<YjczEmergencyProcessTemplate> list = yjczEmergencyProcessTemplateService.selectYjczEmergencyProcessTemplateList(yjczEmergencyProcessTemplate);
        ExcelUtil<YjczEmergencyProcessTemplate> util = new ExcelUtil<YjczEmergencyProcessTemplate>(YjczEmergencyProcessTemplate.class);
        util.exportExcel(response, list, "应急处置操作流程模板数据");
    }

    /**
     * 获取应急处置操作流程模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('yjcz:template:query')")
    @GetMapping(value = "/{pkId}")
    public AjaxResult getInfo(@PathVariable("pkId") Long pkId)
    {
        return success(yjczEmergencyProcessTemplateService.selectYjczEmergencyProcessTemplateByPkId(pkId));
    }

    /**
     * 新增应急处置操作流程模板
     */
    @PreAuthorize("@ss.hasPermi('yjcz:template:add')")
    @Log(title = "应急处置操作流程模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjczEmergencyProcessTemplate yjczEmergencyProcessTemplate)
    {
        return toAjax(yjczEmergencyProcessTemplateService.insertYjczEmergencyProcessTemplate(yjczEmergencyProcessTemplate));
    }

    /**
     * 修改应急处置操作流程模板
     */
    @PreAuthorize("@ss.hasPermi('yjcz:template:edit')")
    @Log(title = "应急处置操作流程模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjczEmergencyProcessTemplate yjczEmergencyProcessTemplate)
    {
        return toAjax(yjczEmergencyProcessTemplateService.updateYjczEmergencyProcessTemplate(yjczEmergencyProcessTemplate));
    }

    /**
     * 删除应急处置操作流程模板
     */
    @PreAuthorize("@ss.hasPermi('yjcz:template:remove')")
    @Log(title = "应急处置操作流程模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pkIds}")
    public AjaxResult remove(@PathVariable Long[] pkIds)
    {
        return toAjax(yjczEmergencyProcessTemplateService.deleteYjczEmergencyProcessTemplateByPkIds(pkIds));
    }

    /**
     * 查询应急处置操作流程模板列表
     */
    @GetMapping("/listTemplate/{sceneId}")
    public AjaxResult listTemplate(@PathVariable("sceneId") String sceneId)
    {
        List<YjczEmergencyProcessTemplate> list = yjczEmergencyProcessTemplateService.selectTemplateListBySceneId(sceneId);
        return success(list);
    }
}
